package com.letu.log.point;


import com.letu.core.point.AllLogBasePoint;
import com.letu.core.point.LogBasePoint;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import java.util.function.Consumer;


/**
 * 异步监听埋点日志事件
 *
 * @author ligang
 * @date 2023-02-05 15:13
 */
@Slf4j
@AllArgsConstructor
public class AllLogPointLogListener {

    private final Consumer<AllLogBasePoint> consumer;

    @Async
    @Order
    @EventListener(AllLogPointEvent.class)
    public void saveSysLog(AllLogPointEvent event) {
        // TODO: 2022/1/21 监听埋点 
        AllLogBasePoint allLogBasePoint = (AllLogBasePoint) event.getSource();
        consumer.accept(allLogBasePoint);
    }

}
